import { getLogin } from '@/request/api/home'
import {getMusicLyric } from '@/request/api/item'
 import { createStore } from 'vuex'

export default createStore({
  state: {
    playList:[{
    al:{
      id: 35702116,
    name: "哪里都是你",
      pic: 109951162964628420,
      picUrl: "https://p2.music.126.net/lnOnBbP_H-052Hv5ls-QjA==/109951162964628408.jpg",
      pic_str: "109951162964628408"
    },
    id:488249475,
    ar:[{
      id: 1143033, name: '队长',
    }]
    }],
    playListIndex:0,
    isBtn:true,
    detailShow:false,
    lyricList:{},
    currentTime:0,
    duration:0,
    // 判断是否登录
    isLogin:false,
    footerShow:false,
    user:{},
  },
  getters: {
  },
  mutations: {
    updateShow:function(state,value){
      state.isBtn=value
    },
    updatePlaylist:function(state,value){
      state.playList=value
    },
    updateIndex(state,value){
      state.playListIndex=value
    },
    pushIndex(state,value){
  state.playList.push(value)
    },
    updateDetailShow(state){
      state.detailShow=!state.detailShow
    },
    updateMusicLyric(state,value){
    state.lyricList=value
    },
    updateCurrentTime(state,value){
      // console.log(state.currentTime)
      state.currentTime=value
    },
     updateDuration(state,value){
      state.duration=value
    },
    updateLogin(state,value){
      state.isLogin=true
    },
    updateUser(state,value){
      state.user=value
    }
  },
  actions: {
    getLyric:async function(context,value){
      let lyricList =await getMusicLyric(value);
      context.commit('updateMusicLyric',lyricList.data.lrc)
    }
    // getQrLogin:async function(context,value){
    //   let userInfo =await qrCodeLoginKey(value)
    //   console.log(userInfo);
    // }
  },
  modules: {
  }
})
